export default class Car{
    arr;
    goodsdata
    constructor(){
        this.usermsg = JSON.parse(sessionStorage.getItem("usermsg"));
        this.username = document.getElementById("username");
        if (this.usermsg) this.writeUserMsg();
        this.id = location.hash.split("=")[1];
        this.center=document.querySelector(".center")
        this.goodsdata = null;
        this.goodsId = [];
        this.arr=[];
            // 获取本地所有数据
        this.cart_data = this.getCartData();
        console.log( this.cart_data);
      
        this.detId = "";
        this.priceall = 0;
        this.choseNum = 0;
        this.getPro();
        this.selectProList();
        this.render()
     
    }
    
    getPro(){
        this.goodsdata = localStorage.getItem("cart");
        console.log(this.goodsdata);
    }
    selectProList(){
    }
    getCartData(){
        try {
            let data = JSON.parse(localStorage.getItem("cart"))
            if (data === null) {
                return {}
            }
            return data;
        } catch (e) {
            return {};
        }
    }

    writeUserMsg() {

        this.username.innerHTML = this.usermsg.username
        this.username.className = "login"
        // console.log("登录");
        }

render(){
    for (var key in JSON.parse(this.goodsdata)) {
        this.arr.push(JSON.parse(this.goodsdata)[key])
    }
    console.log(this.arr);
    
}





}

new Car();